package com.gt.wxpay.cashier.payment.application;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gt.wxpay.cashier.domain.Result;
import com.gt.wxpay.cashier.domain.dto.PayRespDto;
import com.gt.wxpay.cashier.domain.dto.QueryOrderDto;
import com.gt.wxpay.cashier.domain.dto.QueryRefundDto;
import com.gt.wxpay.cashier.domain.model.CashierPayment;

import java.util.List;

/**
 * 支付记录服务接口
 *
 * @author cztech
 */
public interface PaymentService extends IService<CashierPayment> {

    /**
     * 下单
     *
     * @param cashierPayment cashierPayment
     * @return PayRespDto
     */
    PayRespDto order(CashierPayment cashierPayment);

    /**
     * 查询支付记录
     *
     * @param paymentNo paymentNo
     * @return CashierPayment
     */
    CashierPayment queryByPamentNo(String paymentNo);

    CashierPayment queryByPamentNo(String paymentNo, Integer code);

    /**
     * 查询支付记录--微信侧同步
     *
     * @param paymentNo paymentNo
     * @return CashierPayment
     */
    QueryOrderDto queryInfo(String paymentNo);

    /**
     * 退款接口
     *
     * @param cashierPayment cashierPayment
     * @return Result
     */
    Result<QueryRefundDto> refund(CashierPayment cashierPayment);


    /**
     * 关闭订单
     *
     * @param paymentNo paymentNo
     * @return Result
     */
    Result<String> closeOrder(String paymentNo);

    /**
     * 退款查询接口
     *
     * @param refundNo refundNo
     * @return QueryRefundDto
     */
    QueryRefundDto queryRefund(CashierPayment refundNo);

    /**
     * 获取为完成订单
     *
     * @param currentTime currentTime
     * @param whereIn     whereIn
     * @return List
     */
    List<CashierPayment> listAllByThisDayAndStatusNotSuccessOrNotFail(String currentTime, List<Integer> whereIn);

    /**
     * 获取为完成订单
     *
     * @param currentTime currentTime
     * @param whereIn     whereIn
     * @return List
     */
    List<CashierPayment> listNotEndingOrderByPage(String currentTime, String TimeOutValue, List<Integer> whereIn, IPage<CashierPayment> page);


    /**
     * 获取为完成订单
     *
     * @param timeOutValue currentTime
     * @param whereIn      whereIn
     * @return List
     */
    List<CashierPayment> listNeedCloseOrderByPage(String timeOutValue, List<Integer> whereIn, IPage<CashierPayment> page);


    /**
     * 获取商户侧退款失败的订单
     *
     * @param merchantRefundAbnormalValue merchantRefundAbnormalValue
     * @param transactionTypeValue        transactionTypeValue
     * @return CashierPayment
     */
    List<CashierPayment> listAllByMerchantRefundFailTry(Integer merchantRefundAbnormalValue, Integer transactionTypeValue);

    /**
     * 获取当前商户的退款失败的订单
     * @param merchantId merchantId
     * @param merchantRefundAbnormalValue merchantRefundAbnormalValue
     * @param transactionTypeValue transactionTypeValue
     * @return List
     */
    List<CashierPayment> listAllByThatMerchantFailRefundOrder(String merchantId, Integer merchantRefundAbnormalValue, Integer transactionTypeValue);

    CashierPayment getByPamentNo(String paymentNo);
}
